From: Paul Eggert Date: Sat, 18 Jun 2011 15:39:24 +0000 (-0700) Subject: * alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~324^2~3371^2~59 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=63ca15556ee9669319b0414d48d096a9f1578dc5;p=emacs.git * alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication. --- diff --git a/src/ChangeLog b/src/ChangeLog index e01e7ed7ece..e3715ba0d6e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2011-06-18 Paul Eggert + * alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication. + * fns.c (concat): Catch string overflow earlier. Do not rely on integer wraparound. diff --git a/src/alloc.c b/src/alloc.c index 00d330c1b6a..69623d103c3 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2257,12 +2257,14 @@ LENGTH must be a number. INIT matters only in whether it is t or nil. */) p = XBOOL_VECTOR (val); p->size = XFASTINT (length); - memset (p->data, NILP (init) ? 0 : -1, length_in_chars); + if (length_in_chars) + { + memset (p->data, ! NILP (init) ? -1 : 0, length_in_chars); - /* Clear the extraneous bits in the last byte. */ - if (XINT (length) != length_in_chars * BOOL_VECTOR_BITS_PER_CHAR) - p->data[length_in_chars - 1] - &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; + /* Clear any extraneous bits in the last byte. */ + p->data[length_in_chars - 1] + &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; + } return val; }